package vns.server.domain;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;
import vns.client.helper.Eperm;
import vns.shared.PermDTO;

@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")


public class Perm {
	
    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key id;
    
    @Persistent
    private String roleID;
	
    @Persistent
    private String propertyID;
    
	@Persistent 
	private Eperm perm;
	
	
	public Perm(PermDTO permDTO){
		this.perm=permDTO.getEperm();
		this.propertyID=permDTO.getObjectpropertyID();
		this.roleID=permDTO.getRoleID();
	}
	
	public void updatefromDTO(PermDTO permDTO){
		this.perm=permDTO.getEperm();
	}
	
	public PermDTO toDTO(){
		PermDTO permDTO=new PermDTO(this.id,this.perm,this.propertyID,this.roleID);
		return permDTO;
	}
	
	public Key getId(){
		return id;
	}
	
	public Eperm getEperm(){
		return perm;
	}
	
	public void setEperm(Eperm eperm){
		this.perm=eperm;
	}

	public void setRoleID(String roleID) {
		this.roleID = roleID;
	}

	public String getRoleID() {
		return roleID;
	}

	public void setPropertyID(String propertyID) {
		this.propertyID = propertyID;
	}

	public String getPropertyID() {
		return propertyID;
	}
	

}
